#include<iostream>
#include<algorithm>

using namespace std;

const long long mod=1e9+7; 

int n; 


int main()
{
	cin>>n;
	
	cout<<n*(n+1)%(mod*6)*(n-1)%(mod*6)/6<<endl;
	
	return 0;
} 
